import store from "../../store";
import { BASE_URL, ENV } from "../core/env";

export const uploadFile = (url, file) => {
  return new Promise((resolve, reject) => {
    uni.uploadFile({
      url: BASE_URL[ENV] + url,
      filePath: file.url,
      name: 'file',
      formData: {
        fileName: 'test.jpg',
      },
      header: {
        Authorization: store.getters['user/token']
      },
      success: (res) => {
        resolve(res);
      },
      fail: (err) => {
        reject(err);
      },
      complete: (err) => {
        reject(err);
      }
    });
  })
}
